package IC.AST.nodes;

import java.util.List;
import IC.AST.*;

/**
 * a method declaration
 */
public class MethodDecl extends ASTNode {
	private String methodName;	// the method name
	private Type returnType;	// the return type
	private List<FormalDecl> formals;	// the formal arguments
	private Statement body;	// the method body
	private boolean isStatic;	// whether the method is static

	/**
	 * @param methodName the method name
	 * @param returnType the return type
	 * @param formals the formal arguments
	 * @param body the method body
	 * @param isStatic whether the method is static
	 * @param line the node line number
	 * @param column the node column number
	 */
	public MethodDecl(String methodName, Type returnType, List<FormalDecl> formals, Statement body, boolean isStatic, int line, int column) {
		super(line,column);
		this.methodName = methodName;
		this.returnType = returnType;
		this.formals = formals;
		this.body = body;
		this.isStatic = isStatic;
	}

	/**
	 * @return the method name
	 */
	public String getMethodName() {
		return this.methodName;
	}

	/**
	 * @return the return type
	 */
	public Type getReturnType() {
		return this.returnType;
	}

	/**
	 * @return the formal arguments
	 */
	public List<FormalDecl> getFormals() {
		return this.formals;
	}

	/**
	 * @return the method body
	 */
	public Statement getBody() {
		return this.body;
	}

	/**
	 * @return whether the method is static
	 */
	public boolean isStatic() {
		return this.isStatic;
	}

	public Object accept(Visitor v) {
		return v.visit(this);
	}
}
